package cn.initcap.algorithm.data.structures.binary;

import java.util.ArrayList;
import java.util.Random;

/**
 * @author initcap
 * @date Created in 2018/6/26 PM5:07.
 */
public class Test {

    public static void main(String[] args) {
        BinarySearchTree<Integer> binarySearchTree = new BinarySearchTree<>();
        int[] nums = {5, 3, 6, 8, 4, 2};
        for (int num : nums) {
            binarySearchTree.add(num);
        }

        binarySearchTree.preOrder();
        System.out.println();

        binarySearchTree.inOrder();
        System.out.println();

        binarySearchTree.postOrder();
        System.out.println();

        BinarySearchTree<Integer> tree = new BinarySearchTree<>();
        Random random = new Random();

        int n = 100;

        for (int i = 0; i < n; i++) {
            tree.add(random.nextInt(1000));
        }

        ArrayList<Integer> numbers = new ArrayList<>();
        while (!tree.isEmpty()) {
            numbers.add(tree.removeMax());
        }

        System.out.println(numbers);
    }
}
